package com.example.fly.pushdemo.smack.extension;

import android.os.Parcel;
import android.os.Parcelable;

import org.jivesoftware.smack.packet.PacketExtension;

/**
 * Created by fly on 2017/4/13.
 *
 * just for close door
 */

public class QrcodeExt implements PacketExtension, Parcelable {

    private String token;

    public String getQrCode() {
        return qrCode;
    }

    public void setQrCode(String qrCode) {
        this.qrCode = qrCode;
    }

    private String qrCode;


    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }


    @Override
    public String getElementName() {
        return "query";
    }

    @Override
    public String getNamespace() {
        return "urn:ltb:device:open";
    }

    @Override
    public String toXML() {
        StringBuilder sb = new StringBuilder();
        sb.append("<");
        sb.append(getElementName());
        sb.append(" xmlns = \"" + getNamespace() + "\"");
        sb.append(">");

        sb.append("<token>");
        sb.append(getToken());
        sb.append("</token>");

        sb.append("<qrcode>");
        sb.append(getQrCode());
        sb.append("</qrcode>");
        sb.append("</");
        sb.append(getElementName());
        sb.append(">");
        return sb.toString();
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.token);
        dest.writeString(this.qrCode);
    }

    public QrcodeExt() {
    }

    protected QrcodeExt(Parcel in) {
        this.token = in.readString();
        this.qrCode = in.readString();
    }

    public static final Parcelable.Creator<QrcodeExt> CREATOR = new Parcelable.Creator<QrcodeExt>() {
        @Override
        public QrcodeExt createFromParcel(Parcel source) {
            return new QrcodeExt(source);
        }

        @Override
        public QrcodeExt[] newArray(int size) {
            return new QrcodeExt[size];
        }
    };
}
